#include<bits/stdc++.h>
using namespace std;
typedef struct{
	char sex;
	int father;
	int mother;
}BTNode;
int number;
int judge(int father[],int mother[],int boy,int girl);
int main(){
	int n,m,girl,boy,i,ID;
	cin>>n;
	BTNode BT[100001];
	int father[100001],mother[100001];
	for(i=0;i<100001;i++) {
		father[i]=-1;
		mother[i]=-1;
	}
	for(i=0;i<n;i++){
		cin>>ID;
		cin>>BT[ID].sex>>BT[ID].father>>BT[ID].mother;
		if(BT[ID].father!=-1){
			father[ID]=BT[ID].father;
			BT[BT[ID].father].sex='M';
		}
		if(BT[ID].father==-1){
			father[ID]=-1;
		}
		if(BT[ID].mother!=-1){
			mother[ID]=BT[ID].mother;
			BT[BT[ID].mother].sex='F';
		}
		if(BT[ID].mother==-1){
			mother[ID]=-1;
		}
	}
	cin>>m;
	for(i=0;i<m;i++){
		number=0;
		cin>>boy>>girl;
		if(BT[boy].sex==BT[girl].sex) cout<<"Never Mind"<<endl;
		else {
			if(judge(father,mother,boy,girl)==0){
			cout<<"No"<<endl;
			}
			else cout<<"Yes"<<endl;
		}
	}
}
int judge(int father[],int mother[],int boy,int girl){
	if(boy == -1 || girl == -1)
        return 1;
    if((mother[girl]!=-1&&mother[boy] != -1 && mother[boy] == mother[girl]) || (father[girl]!=-1&&father[boy] != -1 && father[boy] == father[girl]))
        return 0;
    number++;
    if(number > 4)
        return 1;
    return (judge(father,mother,mother[boy],mother[girl]) && judge(father,mother,father[boy],father[girl]) && judge(father,mother,mother[boy],father[girl]) && judge(father,mother,father[boy],mother[girl]));
}
